package com.xj.driver.mqtt.bean;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author sunzhenzhen
 */
public enum ControlCommand {
    ON("2", ControlConstants.HOT_STANDBY_ON),
    OFF("1", ControlConstants.HOT_STANDBY_OFF),

    PRE_ON("3", ControlConstants.HOT_STANDBY_PRE_ON),
    PRE_OFF("4", ControlConstants.HOT_STANDBY_PRE_OFF);

    private final String code;
    private final String pointDescription;

    ControlCommand(String code, String pointDescription) {
        this.code = code;
        this.pointDescription = pointDescription;
    }

    public static Optional<ControlCommand> fromCode(String code) {
        return Arrays.stream(values())
                .filter(cmd -> cmd.code.equals(code))
                .findFirst();
    }

    public String getPointDescription() {
        return pointDescription;
    }

    public String getCode() {
        return code;
    }
}

